package com.example.controller;

import com.example.service.CallerService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2017/5/8.
 * 远程RPC调用
 */
@RestController
@RequestMapping(value = "/rpc")
public class CallerController {
    @Autowired
    private CallerService callerService;

    @RequestMapping(value = "call")
    @HystrixCommand(fallbackMethod = "saveOrUpdateMenuFallback")
    public String call(HttpServletRequest request){
        String a = request.getParameter("a");
        String b = request.getParameter("b");
        return callerService.RPCcall(a,b);
    }

    public String saveOrUpdateMenuFallback(HttpServletRequest request){
        return "error";
    }
}
